package com.example.cloud.utils;

import com.example.cloud.constants.CommonConstants;
import com.example.cloud.model.dto.Result;

import java.util.Map;

/**
 * Created by wangtao on 2018/3/7.
 */
public class ResultUtil {

    public static Result success(){
        Result result = new Result();
        result.setCode(CommonConstants.SUCCESS);
        return result;
    }

    public static Result success(String msg){
        Result result = new Result();
        result.setCode(CommonConstants.SUCCESS);
        result.setMsg(msg);
        return result;
    }

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(CommonConstants.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result success(Object data, Map params){
        Result result = new Result();
        result.setCode(CommonConstants.SUCCESS);
        result.setData(data);
        result.setParams(params);
        return result;
    }

    public static Result fail(){
        Result result = new Result();
        result.setCode(CommonConstants.FAILURE);
        return result;
    }

    public static Result fail(String msg){
        Result result = new Result();
        result.setCode(CommonConstants.FAILURE);
        result.setMsg(msg);
        return result;
    }
}
